package com.yhsimon.state;


//线程的优先级
public class TestPriority {
    public static void main(String[] args) {

        //主线程默认优先级
        System.out.println("Thread-main--->"+Thread.currentThread().getPriority());
        MyPriority myYield=new MyPriority();

        Thread t1=new Thread(myYield);
        Thread t2=new Thread(myYield);
        Thread t3=new Thread(myYield);
        Thread t4=new Thread(myYield);
        Thread t5=new Thread(myYield);


        t1.start();

        t2.setPriority(3);
        t2.start();

        t3.setPriority(Thread.MAX_PRIORITY);//10
        t3.start();

        t4.setPriority(Thread.MIN_PRIORITY);//1
        t4.start();

        t5.setPriority(8);
        t5.start();
    }
}
class MyPriority implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"--->优先级为"+Thread.currentThread().getPriority());
    }
}